$(function () {
    let res = myAjax("/home", {whereShow: 1}, "get");
    console.log(res);
    setNewsData(res.newsDTO);
    setProductData(res.productDTO);
})


function setNewsData(data) {

}

function setProductData(data) {
    if (data == null) return;
    let str = '';
    for (let i = 0; i < data.length; i++) {
        str += '<div>\n' +
            '                        <div><img src="' + data[i].imgHref + '"></div>\n' +
            '                        <div class="font-title single-over" onclick="goToProductDetail(' + data[i].id + ')">' + data[i].name + '</div>\n' +
            '                        <div class="font-content single-over">' + data[i].content + '</div>\n' +
            '                    </div>';
    }
    $("#product").html(str);
}

function goToProductDetail(id) {
    sessionStorage.setItem("productId", id);
    window.open("/html/product-detail.html");
}